/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package unipiloto.edu.co.generador_reportes.service.util;

import java.util.logging.Level;
import java.util.logging.Logger;
import net.sf.jasperreports.engine.JRExporter;
import net.sf.jasperreports.engine.export.JExcelApiExporter;
import net.sf.jasperreports.engine.export.JRCsvExporter;
import net.sf.jasperreports.engine.export.JRHtmlExporter;
import net.sf.jasperreports.engine.export.JRPdfExporter;
import net.sf.jasperreports.engine.export.JRRtfExporter;
import net.sf.jasperreports.engine.export.JRXhtmlExporter;
import net.sf.jasperreports.engine.export.JRXlsExporter;
import net.sf.jasperreports.engine.export.JRXmlExporter;
import net.sf.jasperreports.engine.export.oasis.JROdsExporter;
import net.sf.jasperreports.engine.export.oasis.JROdtExporter;
import net.sf.jasperreports.engine.export.ooxml.JRDocxExporter;
import net.sf.jasperreports.engine.export.ooxml.JRPptxExporter;
import net.sf.jasperreports.engine.export.ooxml.JRXlsxExporter;

/**
 *
 * @author David
 */
public enum ReportExportFormat {

    RTF(JRRtfExporter.class, "application/rtf", "rtf"),
    PDF(JRPdfExporter.class, "application/pdf", "pdf"),
    CSV(JRCsvExporter.class, "application/csv", "csv"),
    XML(JRXmlExporter.class, "application/xml", "xml"),
    HTML(JRHtmlExporter.class, "application/html", "html"),
    XLS(JRXlsExporter.class, "application/octet-stream", "xls"),
    JXL(JExcelApiExporter.class, "application/octet-stream", "jxl"),
    ODT(JROdtExporter.class, "application/octet-stream", "odt"),
    ODS(JROdsExporter.class, "application/octet-stream", "ods"),
    DOCX(JRDocxExporter.class, "application/octet-stream", "docx"),
    XLSX(JRXlsxExporter.class, "application/octet-stream", "xlsx"),
    PPTX(JRPptxExporter.class, "application/octet-stream", "pptx"),
    XHTML(JRXhtmlExporter.class, "application/octet-stream", "xhtml");

    private Class<? extends JRExporter> exporterClass;
    private String contentType;
    private String extension;

    private ReportExportFormat(Class<? extends JRExporter> exporterClass, String contentType, String extension) {
        this.exporterClass = exporterClass;
        this.contentType = contentType;
        this.extension = extension;
    }

    public JRExporter crearExporter() {
        try {
            return exporterClass.newInstance();
        } catch (InstantiationException e) {
            Logger.getLogger(ReportExportFormat.class.getName()).log(Level.SEVERE, null, e);
        } catch (IllegalAccessException e) {
            Logger.getLogger(ReportExportFormat.class.getName()).log(Level.SEVERE, null, e);
        }
        return null;
    }

    public String getContentType() {
        return contentType;
    }

    public String getExtension() {
        return extension;
    }
}
